package com.coreJava.test02.xiancheng;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 作者: LCG
 * 日期: 2019/9/4 10:47
 * 描述:
 */
public class MyRejectedExecttionHandler implements RejectedExecutionHandler {

    private LinkedBlockingQueue<Runnable> linkedBlockingQueue;

    public MyRejectedExecttionHandler(LinkedBlockingQueue<Runnable> linkedBlockingQueue) {
        this.linkedBlockingQueue = linkedBlockingQueue;
    }

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {

        try {
            linkedBlockingQueue.put(r);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
